﻿using System;
using System.Collections.Generic;
 
using System.Text;

 /// <summary>
 /// 角色基类
 /// </summary>
 public abstract class ICharacterAttr
 {
     /// <summary>
     /// 名称
     /// </summary>
     protected string mName;

     /// <summary>
     /// 最大血量
     /// </summary>
     protected int mMaxHP;

     /// <summary>
     /// 移动速度
     /// </summary>
     protected float mMoveSpeed;

     /// <summary>
     /// 当前血量
     /// </summary>
     protected int mCurrentHP;

     /// <summary>
     /// 游戏角色头像信息
     /// </summary>
     protected String mIconSprite;

     /// <summary>
     /// 等级
     /// </summary>
     protected int mLv;

     /// <summary>
     /// 0-1之间 敌人才有暴击
     /// </summary>
     protected float mCritRate;
 
    /// <summary>
    /// 策略模式 策略 增加的最大血量  低于最大伤害  暴击增加伤害
    /// </summary>
    protected IAttrStrategy mStrategy;
    /// <summary>
    /// 减免伤害值
    /// </summary>
     protected int mDmgDescValue;

     public int currentHP {   get { return mCurrentHP; }   }

     public ICharacterAttr(IAttrStrategy strategy)   {
         mStrategy = strategy;
         mDmgDescValue = mStrategy.GetDmgDescValue(mLv);
         mCurrentHP = mMaxHP + mStrategy.GetExtraHPValue(mLv);
     }

     /// <summary>
    /// 获取暴击伤害
    /// </summary>
     public int critValue { get { return mStrategy.GetCritDmg(mCritRate); }   }
    /// <summary>
    /// 获得减免血量(防御)
    /// </summary>
     public int dmgDescValue {  get { return mDmgDescValue; }  }

     public void TakeDamage(int damage)
     {
         damage -= mDmgDescValue;
         if (damage < 5) damage = 5;
         mCurrentHP -= damage;
     }
 }
 
